﻿CREATE VIEW [dbo].MV_CMS_Core_Count WITH SCHEMABINDING
 AS 
SELECT  [dbo].[CMS_Cores].[CategoryId] ,  [dbo].[CMS_Cores].[IsDeleted]  ,  [dbo].[CMS_Cores].[IsChecked]  ,  count_big(*) as count FROM  [dbo].[CMS_Cores]   
GROUP BY  [dbo].[CMS_Cores].[CategoryId],  [dbo].[CMS_Cores].[IsDeleted],  [dbo].[CMS_Cores].[IsChecked]  

GO
 
CREATE UNIQUE CLUSTERED INDEX [IX_MV_CMS_Core_Count] ON [dbo].MV_CMS_Core_Count
(
	[CategoryId] ASC,
	[IsDeleted] ASC,
	[IsChecked] ASC
)WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF) ON [PRIMARY]

/****** Object:  View [dbo].[MV_CMS_CoreTags]    Script Date: 2015/3/29 13:02:56 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[MV_CMS_CoreTags]'))
EXEC sp_executesql @statement = N'
/*Tag列表的统计数据量用的*/
CREATE VIEW [dbo].[MV_CMS_CoreTags]
WITH SCHEMABINDING 
AS
SELECT	CMS_CoreTags.TagID, COUNT_BIG(*) AS Count
FROM	dbo.CMS_CoreTags INNER JOIN dbo.CMS_Cores ON CMS_CoreTags.ContentID = CMS_Cores.Id
GROUP BY CMS_CoreTags.TagID

' 
GO
